<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
<!--      <el-form-item label="使用科室" prop="sapProof">-->
<!--        <el-select v-model="queryParams.sapProof" placeholder="请选择使用科室" clearable>-->
<!--          <el-option-->
<!--            v-for="dict in dict.type.reg_is_state"-->
<!--            :key="dict.value"-->
<!--            :label="dict.label"-->
<!--            :value="dict.value"-->
<!--          />-->
<!--        </el-select>-->
<!--      </el-form-item>-->
      <el-form-item label="资产分类" prop="assetType">
        <el-select v-model="queryParams.assetType" placeholder="请选择资产类型" clearable>
          <el-option
            v-for="dict in dict.type.asset_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="资产名称" prop="assetName">
        <el-input
          v-model="queryParams.assetName"
          placeholder="请输入资产名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="spec">
        <el-input
          v-model="queryParams.spec"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="使用情况" prop="ussage">
        <el-select v-model="queryParams.ussage" placeholder="请选择资产使用情况" clearable>
          <el-option
            v-for="dict in dict.type.asset_use_state"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="供应商名称" prop="supplierName">
        <el-select clearable style="width: 100%" filterable v-model="queryParams.supplierName" placeholder="供应商" >
          <el-option
            v-for="dict in supplyOptions"
            :key="dict.supplierCode"
            :label="dict.supplierName"
            :value="dict.supplierName"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['sales:Assetfiles:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['sales:Assetfiles:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['sales:Assetfiles:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['sales:Assetfiles:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="info"
            plain
            icon="el-icon-upload2"
            size="mini"
            @click="handleImport"
        >导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          :disabled="multiple"
          icon="el-icon-printer"
          size="mini"
          @click="printt"
        >打印</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="AssetfilesList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
<!--      <el-table-column label="${comment}" align="center" prop="id" />-->
<!--      <el-table-column label="组织代码" align="center" prop="free1" />-->
<!--      <el-table-column width="120" label="组织名称" align="center" prop="free2" />-->
      <el-table-column label="档案编号" align="center" prop="barcode" />
      <!--      <el-table-column label="资产代码" align="center" prop="assetNumber" />-->
      <el-table-column label="分类名称" align="center" prop="assetType" />
      <el-table-column label="子类名称" align="center" prop="assetClass" />
      <el-table-column width="120" label="资产编码" align="center" prop="assetCode" />
      <el-table-column width="120" label="资产名称" align="center" prop="assetName" />
<!--      <el-table-column width="100" label="物料识别码" align="center" prop="free5" />-->
      <el-table-column  width="100"  label="规格型号" align="center" prop="spec" />
      <el-table-column  width="100"  label="单位" align="center" prop="free5" />
      <el-table-column  width="100"  label="数量" align="center" prop="free2" />
      <el-table-column  width="100"  label="品牌" align="center" prop="brand" />
      <el-table-column label="使用科室" align="center" prop="sapProof"/>
      <el-table-column label="科室代码" align="center" prop="receivingUnit" />
      <el-table-column label="资产位置" align="center" prop="assetPosition" />
      <el-table-column label="购置金额（元）" align="center" prop="purchaseAmount" />
      <el-table-column label="购置时间" align="center" prop="buyTime" width="180"/>
      <el-table-column width="100" label="资产负责人" align="center" prop="assetHead" />
      <el-table-column  width="100"  label="供应商编码" align="center" prop="supplierCode" />
      <el-table-column  width="100"  label="供应商名称" align="center" prop="supplierName" />
<!--      <el-table-column  width="100"  label="制造商编码" align="center" prop="manufactureCode" />-->
<!--      <el-table-column  width="100"  label="制造商名称" align="center" prop="manufactureName" />-->
      <el-table-column label="使用寿命" align="center" prop="useLife" />
      <el-table-column label="使用情况" align="center" prop="ussage">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.asset_use_state" :value="scope.row.ussage"/>
        </template>
      </el-table-column>
<!--      <el-table-column label="操作人员" align="center" prop="operator" />-->
      <el-table-column label="启用时间" align="center" prop="activationTime" width="180"/>
      <el-table-column label="资产图片" align="center" prop="assetImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.assetImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column  width="120"  label="资产保养周期" align="center" prop="assetMaintenance" />
      <el-table-column width="120" label="资产维护周期" align="center" prop="assetUphold" />
      <el-table-column width="120" label="资产程序代码" align="center" prop="assetProgramCode" />
      <el-table-column width="120" label="资产程序包" align="center" prop="assetProgramPackage" />
      <el-table-column label="使用年限" align="center" prop="usefulLife" />
      <el-table-column label="折旧年限" align="center" prop="periodOfDepreciation" />
      <el-table-column label="累计折旧" align="center" prop="accumulatedDepreciation" />
      <el-table-column label="净值" align="center" prop="netWorth" />
      <el-table-column label="盘点状态" align="center" prop="inventoryStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.pd_state" :value="scope.row.inventoryStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="出库单号" align="center" prop="danhao" />
      <el-table-column label="填报时间" align="center" prop="fillingTime" width="110"/>
      <el-table-column label="填报人" align="center" prop="fillingBy" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['sales:Assetfiles:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['sales:Assetfiles:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改固定资产档案对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row :gutter="24">
          <el-col :span="24">
            <el-form-item label="使用科室" prop="receivingUnit">
              <treeselect @select="handleSelect"  v-model="form.receivingUnit" :clearable="true" :options="deptOptions" :show-count="true" placeholder="请选择使用科室" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="资产编码" prop="assetCode">
              <el-input v-model="form.assetCode" placeholder="请输入资产编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="资产名称" prop="assetName">
              <el-input v-model="form.assetName" placeholder="请输入资产名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="分类名称" prop="assetType">
              <el-select v-model="form.assetType" placeholder="请选择分类名称">
                <el-option
                  v-for="dict in dict.type.asset_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商" prop="supplierCode">
              <el-select @change = 'handleChange'  style="width: 100%" filterable v-model="form.supplierName" placeholder="供应商" >
                <el-option
                  v-for="dict in supplyOptions"
                  :key="dict.supplierCode"
                  :label="dict.supplierName"
                  :value="dict"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="子类名称" prop="assetClass">
              <el-input v-model="form.assetClass" placeholder="请输入子类名称" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="品牌" prop="brand">
              <el-input v-model="form.brand" placeholder="请输入品牌" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="规格型号" prop="spec">
              <el-input v-model="form.spec" placeholder="请输入规格型号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="购置时间" prop="buyTime">
              <el-date-picker clearable
                v-model="form.buyTime"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择购置时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="资产负责人" prop="asseThead">
              <el-input v-model="form.asseThead" placeholder="请输入资产负责人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="使用寿命" prop="useLife">
              <el-input v-model="form.useLife" placeholder="请输入使用寿命" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="使用情况" prop="ussage">
              <el-select v-model="form.ussage" placeholder="请选择资产使用情况">
                <el-option
                  v-for="dict in dict.type.asset_use_state"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="资产位置" prop="assetPosition">
              <el-input v-model="form.assetPosition" placeholder="请输入资产位置" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="操作人员" prop="operator">
              <el-input v-model="form.operator" placeholder="请输入操作人员" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="启用时间" prop="activationTime">
              <el-date-picker clearable
                v-model="form.activationTime"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择启用时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="24">
            <el-form-item label="资产图片" prop="assetImg">
              <image-upload v-model="form.assetImg"/>
            </el-form-item>
          </el-col>
<!--          <el-col :span="12">-->
<!--            <el-form-item label="资产保养周期" prop="assetMaintenance">-->
<!--              <el-input v-model="form.assetMaintenance" placeholder="请输入资产保养周期" />-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--          <el-col :span="12">-->
<!--            <el-form-item label="资产维护周期" prop="assetUphold">-->
<!--              <el-input v-model="form.assetUphold" placeholder="请输入资产维护周期" />-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--          <el-col :span="12">-->
<!--            <el-form-item label="资产程序代码" prop="assetProgramCode">-->
<!--              <el-input v-model="form.assetProgramCode" placeholder="请输入资产程序代码" />-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--          <el-col :span="12">-->
<!--            <el-form-item label="资产程序包" prop="assetProgramPackage">-->
<!--              <el-input v-model="form.assetProgramPackage" placeholder="请输入资产程序包" />-->
<!--            </el-form-item>-->
<!--          </el-col>-->
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="购置金额" prop="purchaseAmount">
              <el-input v-model="form.purchaseAmount" placeholder="请输入购置金额" />
            </el-form-item>
          </el-col>
<!--          <el-col :span="12">-->
<!--            <el-form-item label="使用年限" prop="usefulLife">-->
<!--              <el-input v-model="form.usefulLife" placeholder="请输入使用年限" />-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--          <el-col :span="12">-->
<!--            <el-form-item label="折旧年限" prop="periodOfDepreciation">-->
<!--              <el-input v-model="form.periodOfDepreciation" placeholder="请输入折旧年限" />-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--          <el-col :span="12">-->
<!--            <el-form-item label="累计折旧" prop="accumulatedDepreciation">-->
<!--              <el-input v-model="form.accumulatedDepreciation" placeholder="请输入累计折旧" />-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--          <el-col :span="12">-->
<!--            <el-form-item label="净值" prop="netWorth">-->
<!--              <el-input v-model="form.netWorth" placeholder="请输入净值" />-->
<!--            </el-form-item>-->
<!--          </el-col>-->
          <el-col :span="12">
            <el-form-item label="盘点状态" prop="inventoryStatus">
              <el-select v-model="form.inventoryStatus" placeholder="请选择盘点状态">
                <el-option
                  v-for="dict in dict.type.pd_state"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="填报时间" prop="fillingTime">
              <el-date-picker clearable
                v-model="form.fillingTime"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择填报时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="填报人" prop="fillingBy">
              <el-input v-model="form.fillingBy" placeholder="请输入填报人" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
          ref="upload"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="upload.url + '?updateSupport=' + upload.updateSupport"
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listAssetfiles, getAssetfiles, delAssetfiles, addAssetfiles, updateAssetfiles } from "@/api/sales/Assetfiles";
import {getToken} from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import { getWarehouseInfoByDeptId } from "@/api/base/warehouseinfo";
import { treeselect } from "@/api/system/dept";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {getLiSupplier} from "@/api/supplychain/supplier";
import {getLodop} from "@/common/LodopFuncs";
export default {
  name: "Assetfiles",
  components: {Treeselect},
  dicts: ['asset_type', 'reg_is_state', 'pd_state','asset_use_state'],
  data() {
    return {
      jms:[],
      //供应商字典
      supplyOptions: [],
      warehouseinfo:[],
      deptOptions: undefined,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 固定资产档案表格数据
      AssetfilesList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        assetType: null,
        assetName: null,
        spec: null,
        supplierName: null,
        manufactureName: null,
      },
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "导入`Assetfiles`信息",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/sales/Assetfiles/importData"
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        assetCode: [
          { required: true, message: "资产编码不能为空", trigger: "blur" }
        ],
        assetName: [
          { required: true, message: "资产名称不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
    this.getTreeselect();
    getLiSupplier().then(response => {
      this.supplyOptions = response.data;
    });
  },
  methods: {
    printt(){
      let LODOP = getLodop();
      LODOP.PRINT_INIT("");
      LODOP.PRINT_INITA(0,0,190,94,"");
      for(let i=0;i<this.jms.length;i++){

        LODOP.NewPage();
        LODOP.SET_PRINT_STYLE("FontSize",8);
        LODOP.SET_PRINT_PAGESIZE(1,500,250,"");
        LODOP.ADD_PRINT_BARCODE(21,2,87,134,"QRCode",this.jms[i].assetCode);
        LODOP.ADD_PRINT_TEXT(30,80,90,20,"资产名称:"+this.jms[i].assetName);
        LODOP.ADD_PRINT_TEXT(65,80,90,20,"资产代码:"+this.jms[i].assetNumber);
        //    LODOP.PRINT();

      }


      LODOP.PREVIEW();
    },
    handleChange(e){
      this.form.supplierCode = e.supplierCode
      this.form.supplierName = e.supplierName
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
    handleSelect(selectedNodes) {
      this.form.sapProof = selectedNodes.label;
      this.form.receivingUnit = selectedNodes.id;
    },
    /** 查询固定资产档案列表 */
    getList() {
      this.loading = true;
      listAssetfiles(this.queryParams).then(response => {
        this.AssetfilesList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        sapProof: null,
        receivingUnit: null,
        assetCode: null,
        assetType: null,
        assetClass: null,
        assetName: null,
        brand: null,
        spec: null,
        buyTime: null,
        assetHead: null,
        useLife: null,
        supplierCode: null,
        supplierName: null,
        manufactureCode: null,
        manufactureName: null,
        ussage: null,
        assetPosition: null,
        operator: null,
        activationTime: null,
        assetImg: null,
        assetMaintenance: null,
        assetUphold: null,
        assetProgramCode: null,
        assetProgramPackage: null,
        purchaseAmount: null,
        usefulLife: null,
        periodOfDepreciation: null,
        accumulatedDepreciation: null,
        netWorth: null,
        inventoryStatus: null,
        remark: null,
        fillingTime: null,
        fillingBy: null,
        free1: null,
        free2: null,
        assetNumber: null,
        barcode: null,
        free5: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
      this.jms = selection.map((item) => {
        return{
          assetName:item.assetName,
          assetCode:item.assetCode,
          assetNumber:item.assetNumber,
          spec:item.spec,
          buyTime:item.buyTime,
        }
      })
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加固定资产档案";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getAssetfiles(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改固定资产档案";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateAssetfiles(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addAssetfiles(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除数据？').then(function() {
        return delAssetfiles(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('sales/Assetfiles/export', {
        ...this.queryParams
      }, `Assetfiles_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "固定资产档案导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('sales/Assetfiles/importTemplate', {
      }, `固定资产档案模板.xlsx`)
    },
    /** 文件上传中处理 */
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    /** 文件上传成功处理 */
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    /** 提交上传文件 */
    submitFileForm() {
      this.$refs.upload.submit();
    },
  }
};
</script>
